using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using Entities;
using BUS;
using Utility;

public partial class Admin_TTGiaoDichUpdate : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            LoadData();
        }
    }
    private void LoadData()
    {
        try
        {
            int id = int.Parse(Request.QueryString["id"].ToString());
            txt_id_gd.Text = id.ToString();
            tbTTGiaoDich ttgd = tbTTGiaoDichBus .GetByID(id);
            txt_ttgd.Text = ttgd.GiaoDich ;
            tbHTThanhToan  .tbHTThanhToanCollection  httt_collection = tbHTThanhToanBus .GetAll();
            ddl_httt.DataTextField = tbHTThanhToan .tbHTThanhToanColumns .TenHinhThuc .ToString();
            ddl_httt.DataValueField = tbHTThanhToan.tbHTThanhToanColumns.IDHinhThuc.ToString();
            ddl_httt.DataSource = httt_collection;
            ddl_httt.DataBind();
        }
        catch
        {
            Response.Redirect("TTGiaoDichList.aspx");
        }
    }
    protected void btn_Update_Click(object sender, EventArgs e)
    {
        int id = int.Parse(Request.QueryString["id"].ToString());
        tbTTGiaoDich ttgd = tbTTGiaoDichBus .GetByID(id);
        ttgd.IDTTGiaoDich  = int.Parse(txt_id_gd.Text);
        ttgd.GiaoDich  = txt_ttgd.Text;
        ttgd.IDHinhThuc = int.Parse(ddl_httt.SelectedValue);
        ttgd.ThanhTien  = int.Parse(txt_sotien.Text);
        
        tbTTGiaoDichBus .Update_TTGiaoDich(ttgd);
        Response.Redirect("TTGiaoDichList.aspx");
    }
}
